<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        button {
            width: 100px;
            height: 50px;
        }
    </style>
</head>

<body>
    <button id="btn"></button>
    <div id="output"></div>
    <script>
        var str = "";
        btn.onclick = function () {
            fetch('demo.json', {
                headers: {
                    'Content-Type': "application/json"
                },
            }).then(res => res.json()).then(data =>
                data.forEach(element => {
                    str += `<p>
                                ${element.age}
                                ${element.name}
                            
                            </p>`
                    document.getElementById('output').innerHTML = str;
                })
            )
        }
    </script>
</body>

</html>